home *** CD-ROM | disk | FTP | other *** search
- /*
- ** ARexx Support
- */
-
- #include "include/config.h"
-
- #include <stdio.h>
- #include <string.h>
- #include <stdarg.h>
-
- #include <proto/exec.h>
- #include <proto/dos.h>
- #include <proto/rexxsyslib.h>
- #include <rexx/storage.h>
-
- #include "include/mui.h"
- #include "include/search.h"
- #include "include/gui.h"
- #include "include/rexx.h"
- #include "amster_Cat.h"
-
- MUIF rexx_con(REG(a0) struct Hook *h,REG(a2) Object *app, REG(a1) char **array);
- MUIF rexx_dis(REG(a0) struct Hook *h,REG(a2) Object *app, REG(a1) char **array);
- MUIF rexx_ison(REG(a0) struct Hook *h,REG(a2) Object *app, REG(a1) char **array);
- MUIF rexx_search(REG(a0) struct Hook *h,REG(a2) Object *app, REG(a1) char **array);
- MUIF rexx_sstat(REG(a0) struct Hook *h,REG(a2) Object *app, REG(a1) char **array);
-
- struct Hook rexx_conHook = { {0,0}, &rexx_con, NULL, NULL };
- struct Hook rexx_disHook = { {0,0}, &rexx_dis, NULL, NULL };
- struct Hook rexx_isonHook = { {0,0}, &rexx_ison, NULL, NULL };
- struct Hook rexx_searchHook = { {0,0}, &rexx_search, NULL, NULL };
- struct Hook rexx_sstatHook = { {0,0}, &rexx_sstat, NULL, NULL };
-
- struct MUI_Command rexx_cmds[] = {
- { "connect", NULL, 0, &rexx_conHook },
- { "disconnect", NULL, 0, &rexx_disHook },
- { "isonline", NULL, 0, &rexx_isonHook },
- { "search", "TITLE/A", 1, &rexx_searchHook },
- { "searchstate", NULL, 0, &rexx_sstatHook },
- { NULL, NULL, 0, NULL }
- };
-
-
- MUIF rexx_con(REG(a0) struct Hook *h,REG(a2) Object *app, REG(a1) char **array)
- {
- if (!gui_napon) nap_login();
- return(0);
- }
-
-
- MUIF rexx_dis(REG(a0) struct Hook *h,REG(a2) Object *app, REG(a1) char **array)
- {
- nap_logout();
- set(gui->stat, MUIA_Text_Contents, MSG_STATUS2_NOTCONNECTED);
- return(0);
- }
-
-
- MUIF rexx_ison(REG(a0) struct Hook *h,REG(a2) Object *app, REG(a1) char **array)
- {
- if (gui_napon) return(1); else return(0);
- }
-
-
- MUIF rexx_search(REG(a0) struct Hook *h,REG(a2) Object *app, REG(a1) char **array)
- {
- DoMethod(gui->searchpanel, SEARCH_GO, array[0]);
- return(0);
- }
-
-
- MUIF rexx_sstat(REG(a0) struct Hook *h,REG(a2) Object *app, REG(a1) char **array)
- {
- return((ULONG)search_state);
- }
-
-
- u_long rexx_sendcommand(char *port, char *com)
- {
- struct MsgPort *me,*him;
- struct RexxMsg *rmsg;
- u_long rc=0;
-
- if(me=CreateMsgPort()) {
- if(rmsg=CreateRexxMsg(me,NULL,NULL)) {
- if(rmsg->rm_Args[0]=CreateArgstring(com,strlen(com))) {
- rmsg->rm_Action = RXCOMM;
- Forbid();
- if(him=FindPort(port)) {
- PutMsg(him,(struct Message *)rmsg);
- WaitPort(me);
- GetMsg(me);
- rc = rmsg->rm_Result1;
- }
- Permit();
- DeleteArgstring(rmsg->rm_Args[0]);
- }
- DeleteRexxMsg(rmsg);
- }
- DeleteMsgPort(me);
- }
- return(rc);
- }
-
-
- void rexx_execute(char *com, char *argfmt, ...)
- {
- static char buf[1024];
- char *p;
- va_list ap;
-
- p = buf + sprintf(buf,"Run <>NIL: RexxC:RX %s ",com);
- if(argfmt) {
- va_start(ap,argfmt);
- vsprintf(p,argfmt,ap);
- va_end(ap);
- }
-
- Execute(buf,0,0);
- }
-